#ifndef HAVE_TEXT2XML_LIST_H
#define HAVE_TEXT2XML_LIST_H

#ifdef __cplusplus
extern "C" {
#endif
  typedef struct _List List;

  struct _List {
    void* data;
    List* next;
    List* prev;
  };

  /**
   * Returns a new list.
   */
  List* list_new(void);

  /**
   * Destroys the list.
   */
  void list_free(List* list);

  /**
   * Removes all items from the list. Returns the
   * empty list.
   */
  List* list_clear(List* list);

  /**
   * Appends a new item at the end of the specified list.
   * Returns a pointer to the first element of the list.
   */
  List* list_append(List* list, void* data);

  /**
   * Removes the specified item from the specified item list.
   * Returns a pointer to the first element of the list.
   */
  List* list_remove(List* list, List* item);

  /**
   * Removes all items that point to the given data from the specified
   * item list.
   * Returns a pointer to the first element of the list.
   */
  List* list_remove_data(List* list, void* data);

  /**
   * Returns the first item with the given data.
   */
  List* list_find_data(List* list, void* data);

  /**
   * Returns the number of elements in the specified list.
   */
  int list_length(List* list);

  /**
   * Returns the first item from the specified list.
   * or NULL if the list is empty.
   */
  List* list_get_first(List* list);

  /**
   * Returns the last item from the specified list.
   * or NULL if the list is empty.
   */
  List* list_get_last(List* list);
#ifdef __cplusplus
}
#endif                          /* __cplusplus */

#include "ListIter.h"

#endif                          /* HAVE_TEXT2XML_LIST_H */
